<?php

namespace App\Http\Services\FormBuilder\Elements;
use App\Http\Repositories\FileRepository;

class File extends Input
{
    protected $attributes = [
        'type' => 'file',
    ];

    public function render()
    {
        return '';
    }

    public function defaultValue($value)
    {
        if (!$this->hasValue()) {
            $this->setValue($value);
        }

        return $this;
    }

    protected function hasValue()
    {
        return isset($this->attributes['value']);
    }

    public function editBlock()
    {

        $objectType = 'project';
        $objectId = '11';
        $subObjectKey = 12;

        $files = app(FileRepository::class)->getFilesByObject($objectType, $objectId, $subObjectKey);

        $html = view('element.file.edit_block',[
            'name' => $this->getAttribute('name'),
            'objectType' => $objectType,
            'objectId'=> $objectId,
            'subObjectKey' =>$subObjectKey,
            'displayName' => $this->getAttribute('display_name'),
            'liClass' => $this->getAttribute('li_class'),
            'existFiles' => $files,
        ])->render();



        return $html;
    }

}
